PopupArea = function (trigger,area,adaptor)
{
	
	var self = this;
	
	this.show_timeout = 100;
	this.show_timer = false;
	this.triggerEl = this.getElement(trigger);
	this.areaEl = this.getElement(area);
	
	adaptor(self);

}

PopupArea.prototype.getElement = function (el)
{
	if (typeof el == "string")
		return document.getElementById(el);
	else
		return el;
}

PopupArea.prototype.show = function (self) 
{
	if (self.show_timer!=false) window.clearTimeout(self.show_timer);
	self.areaEl.style.display = "block";
}

PopupArea.prototype.hide = function (self)
{
	self.show_timer = window.setTimeout(function () { self.do_hide(self) }, self.show_timeout);

}

PopupArea.prototype.do_hide = function (el) 
{
	el.areaEl.style.display = "none";
}



var PopupAreaAdaptors;
if (!PopupAreaAdaptors) PopupAreaAdaptors = {};

PopupAreaAdaptors.SplashUnderTrigger = function (self) {
	if (navigator.appName=="MSIE" || navigator.appName.indexOf('Microsoft')!='-1') {
		self.triggerEl.attachEvent("onmouseover",function () { self.show(self) });
		self.triggerEl.attachEvent("onmouseout",function () { self.hide(self) });
		self.areaEl.attachEvent("onmouseover",function () { self.show(self) });
		self.areaEl.attachEvent("onmouseout",function () { self.hide(self) });
	} else {
		self.triggerEl.addEventListener("mouseover",function () { self.show(self) },true);
		self.triggerEl.addEventListener("mouseout",function () { self.hide(self) },true);
		self.areaEl.addEventListener("mouseover",function () { self.show(self) },true);
		self.areaEl.addEventListener("mouseout",function () { self.hide(self) },true);
	}
	
	/*self.triggerEl.attachEvent("onmouseover",function () { self.show(self) });
	self.triggerEl.attachEvent("onmouseout",function () { self.hide(self) });
	self.areaEl.attachEvent("onmouseover",function () { self.show(self) });
	self.areaEl.attachEvent("onmouseout",function () { self.hide(self) });*/
}


PopupAreaAdaptors.mouseOverSplashUnderTrigger = function (self) {
	var m_over = function (evt) {
		self.show(self);

		var evt = navigator.appName == 'Microsoft Internet Explorer' ? event : evt;
		var mouseX = evt.clientX;
		var mouseY = evt.clientY;
		var popupWidth  = self.areaEl.offsetWidth;
		var popupHeight = self.areaEl.offsetHeight;
		var docWidth    = document.body.clientWidth;
		var docHeight   = document.body.clientHeight;
		var popupLeft = mouseX+popupWidth  > docWidth  ? mouseX-popupWidth  : mouseX;
		var popupTop  = mouseY+popupHeight > docHeight ? mouseY-popupHeight : mouseY;
		self.areaEl.style.left = popupLeft+'px';
		self.areaEl.style.top  = popupTop+'px';

	};
			
	if (navigator.appName=="MSIE" || navigator.appName.indexOf('Microsoft')!='-1') {
		self.triggerEl.attachEvent("onmouseover",m_over);
		self.triggerEl.attachEvent("onmouseout",function () { self.hide(self) });
		self.areaEl.attachEvent("onmouseover",function () { self.show(self) });
		self.areaEl.attachEvent("onmouseout",function () { self.hide(self) });
	} else {
		self.triggerEl.addEventListener("mouseover",m_over,true);
		self.triggerEl.addEventListener("mouseout",function () { self.hide(self) },true);
		self.areaEl.addEventListener("mouseover",function () { self.show(self) },true);
		self.areaEl.addEventListener("mouseout",function () { self.hide(self) },true);
	}

}

PopupAreaAdaptors.SplashCursorCords = function (self) {

	self.triggerEl.onmousedown = function (evt) {
		var evt = navigator.appName == 'Microsoft Internet Explorer' ? event : evt;
		if ((navigator.appName == 'Netscape' && (evt.which == 3 || evt.which == 2)) || (navigator.appName == 'Microsoft Internet Explorer' && (evt.button == 2 || evt.button == 3))) {
			var mouseX = evt.clientX;
			var mouseY = evt.clientY;
			var popupWidth  = self.areaEl.offsetWidth;
			var popupHeight = self.areaEl.offsetHeight;
			var docWidth    = document.body.clientWidth;
			var docHeight   = document.body.clientHeight;
			var popupLeft = mouseX+popupWidth  > docWidth  ? mouseX-popupWidth  : mouseX;
			var popupTop  = mouseY+popupHeight > docHeight ? mouseY-popupHeight : mouseY;
			self.areaEl.style.left = popupLeft+'px';
			self.areaEl.style.top  = popupTop+'px';

			
			var SavedFn = false;
			if (typeof window.document.body.onclick == 'function')
				SavedFn = window.document.body.onclick;

			window.document.body.onclick = function () {
					self.do_hide(self);
					if (SavedFn!=false) {
						window.document.body.onclick = SavedFn;
					}
				}
				
			//alert(typeof window.document.body.onclick);
			
			self.show(self);
			
		}
	};
	
	
	self.areaEl.onmouseover = function () { self.show(self) };
	self.areaEl.onmouseout = function () { self.hide(self) };
}